import request from "@/utils/Request"


export default class ArticleApiRequest {
    // 上传文章图片
    async uploadArticleImageFile(file) {
        return Promise.resolve(request.postForm("/api/article/image", file));
    }

    // 上传markdown 文章图片
    async uploadMarkdownImageFile(file) {
        return Promise.resolve(request.postForm("/api/article/markdown/image", file));
    }

    // 添加文章
    async addArticle(data) {
        return Promise.resolve(request.postForm("/api/article/add", data))
    }

    //修改文章信息
    async updateArticle(data) {
        return Promise.resolve(request.postForm("/api/article/update", data))
    }

    //单个文章信息获取
    async showArticle(id, data) {
        return Promise.resolve(request.restFul("/api/article/showBlog/{id}", { id }, data))
    }

    // 单个文章评论信息获取
    async showArticleComment(data) {
        return Promise.resolve(request.restFul("/api/comment/list/{articleId}", { articleId: data }))
    }

    // 发送评论
    async sendComment(data) {
        return Promise.resolve(request.postForm("/api/comment/sendComment", data))
    }

    //删除评论
    async delComment(data) {
        return Promise.resolve(request.get("/api/comment/del", data))
    }

    // 点赞文章
    async goodArticle(data) {
        return Promise.resolve(request.postForm("/api/article/addGood", data))
    }

    // 收藏文章
    async starArticle(data) {
        return Promise.resolve(request.postForm("/api/article/addStar", data))
    }

    // 个人中心用户取消收藏文章
    async unStarArticle(data) {
        return Promise.resolve(request.postForm("/api/article/unStar", data))
    }

    // 获取用户的收藏文章信息
    async getUserFavoriteArticle(data) {
        return Promise.resolve(request.postForm("/api/article/favorite", data));
    }

    // 查询文章
    async searchArticle(data) {
        return Promise.resolve(request.postForm("/api/elasticsearch/searchKeyword", data));
    }

    // 获取文章归档信息
    async getArticleArchives() {
        return Promise.resolve(request.get("/api/archives/list"))
    }
}

